package com.sc.nft.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sc.nft.entity.AdvertisementInfo;
import com.sc.nft.mapper.AdvertisementInfoMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * (sc_advertisement_info)数据DAO
 *
 * @author rdg
 * @since 2022-05-30 10:09:02
 * @description 由 Mybatisplus Code Generator 创建
 */
@Slf4j
@Repository
public class AdvertisementInfoDao extends ServiceImpl<AdvertisementInfoMapper, AdvertisementInfo> {

    public List<AdvertisementInfo> getAdvertisementInfos() {
        LambdaQueryWrapper<AdvertisementInfo> advertisementWrapper = new LambdaQueryWrapper<>();
        advertisementWrapper.eq(AdvertisementInfo::getIsOpen,Boolean.TRUE);
        advertisementWrapper.orderByAsc(AdvertisementInfo::getSortRule);
        List <AdvertisementInfo> list = new AdvertisementInfo().selectList(advertisementWrapper);
        return list;
    }
    public Page<AdvertisementInfo> listAdvertisement(int pageNo, int pageSize) {
        LambdaQueryWrapper<AdvertisementInfo> advertisementWrapper = new LambdaQueryWrapper<>();
        advertisementWrapper.orderByAsc(AdvertisementInfo::getSortRule);
        return page(new Page<>(pageNo,pageSize),advertisementWrapper);
    }
}